cmake_minimum_required(VERSION 3.13)
project(snake VERSION 0.1.1)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/static)

include_directories(${CMAKE_SOURCE_DIR}/include)

set(SOURCES
	${CMAKE_SOURCE_DIR}/src/Snake.cpp
	${CMAKE_SOURCE_DIR}/src/Field/AField.cpp
	${CMAKE_SOURCE_DIR}/src/Field/RectShapeField.cpp
	${CMAKE_SOURCE_DIR}/src/App.cpp
	${CMAKE_SOURCE_DIR}/src/Game.cpp
)

# Separated library to avoid linker error undefined reference to <sfml specific>
add_library(libsnake STATIC ${SOURCES})

# Program
find_package(SFML 2.5 COMPONENTS system window graphics REQUIRED)

add_executable(snake ${CMAKE_SOURCE_DIR}/src/main.cpp)
target_link_libraries(snake libsnake)
target_link_libraries(snake sfml-window sfml-graphics sfml-system) #SFML libs

# Tests
file(GLOB_RECURSE TEST_SOURCES ${CMAKE_SOURCE_DIR}/test/*.cpp)

find_package(Catch2 3 REQUIRED)

add_executable(test ${TEST_SOURCES})
target_link_libraries(test PRIVATE libsnake)
target_link_libraries(test PRIVATE Catch2::Catch2WithMain)

